﻿using BLL.Interface;
using Common.Extensions;
using Microsoft.AspNetCore.Mvc;
using Model.DTO.Comment;
using Model.DTO.Public.GetList;
using Model.DTO.Public.OperateId;

namespace TianXiaHuiForumManagementSystem.Controllers.Admin
{
    [Route("Admin/[controller]")]
    [ApiController]
    public class CommentController : ControllerBase
    {
        private readonly ICommentBLL _commentBLL;
        public CommentController(ICommentBLL commentBLL)
        {
            _commentBLL = commentBLL;
        }
        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("AddComment")]
        public async Task<string> AddComment(AddCommentDTO param)
        {
            var result = await _commentBLL.AddComment(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 删除评论
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("DeleteComment")]
        public async Task<string> DeleteComment(OperateIdDTO_LONG param)
        {
            var result = await _commentBLL.DeleteComment(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 编辑评论
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("EditComment")]
        public async Task<string> EditComment(EditCommentDTO param)
        {
            var result = await _commentBLL.EditComment(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 获取评论列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpGet, Route("GetCommentList")]
        public async Task<string> GetCommentList(GetListDTO param)
        {
            var result = await _commentBLL.GetCommentList(param);
            return result.ToJsonFormat();
        }
    }
}
